package o;

import android.graphics.BitmapFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class cms {
    public static byte[] ॱ(String str) {
        Throwable th;
        byte[] bArr = new byte[0];
        File ˋ = cea.ˋ(str);
        if (ˋ != null && ˋ.exists() && ˋ.isFile()) {
            FileInputStream fileInputStream;
            try {
                fileInputStream = new FileInputStream(ˋ);
                try {
                    bArr = ˏ(BitmapFactory.decodeStream(fileInputStream));
                    if (fileInputStream != null) {
                        try {
                            fileInputStream.close();
                        } catch (IOException e) {
                            cmh.ˎ.ˊ("MicroSearchImageUtil", "getImageData in.close()");
                        }
                    }
                } catch (IOException e2) {
                    try {
                        cmh.ˎ.ˊ("MicroSearchImageUtil", "read image file IOException: ");
                        if (fileInputStream != null) {
                            try {
                                fileInputStream.close();
                            } catch (IOException e3) {
                                cmh.ˎ.ˊ("MicroSearchImageUtil", "getImageData in.close()");
                            }
                        }
                        return bArr;
                    } catch (Throwable th2) {
                        th = th2;
                        if (fileInputStream != null) {
                            try {
                                fileInputStream.close();
                            } catch (IOException e4) {
                                cmh.ˎ.ˊ("MicroSearchImageUtil", "getImageData in.close()");
                            }
                        }
                        throw th;
                    }
                }
            } catch (IOException e5) {
                fileInputStream = null;
                cmh.ˎ.ˊ("MicroSearchImageUtil", "read image file IOException: ");
                if (fileInputStream != null) {
                    fileInputStream.close();
                }
                return bArr;
            } catch (Throwable th3) {
                th = th3;
                fileInputStream = null;
                if (fileInputStream != null) {
                    fileInputStream.close();
                }
                throw th;
            }
        }
        return bArr;
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private static byte[] ˏ(android.graphics.Bitmap r5) {
        /*
        r0 = 0;
        if (r5 != 0) goto L_0x0006;
    L_0x0003:
        r0 = new byte[r0];
    L_0x0005:
        return r0;
    L_0x0006:
        r0 = r5.getWidth();
        r1 = r5.getHeight();
        r0 = r0 * r1;
        r0 = r0 * 4;
        r1 = new java.io.ByteArrayOutputStream;
        r1.<init>(r0);
        r0 = android.graphics.Bitmap.CompressFormat.PNG;	 Catch:{ IllegalArgumentException -> 0x003e }
        r2 = 100;
        r5.compress(r0, r2, r1);	 Catch:{ IllegalArgumentException -> 0x003e }
        r0 = r1.toByteArray();	 Catch:{ IllegalArgumentException -> 0x003e }
        r1.flush();	 Catch:{ IOException -> 0x0033 }
    L_0x0024:
        r1.close();	 Catch:{ IOException -> 0x0028 }
        goto L_0x0005;
    L_0x0028:
        r1 = move-exception;
        r1 = o.cmh.ˎ;
        r2 = "MicroSearchImageUtil";
        r3 = "flattenBitmap out.close() IOException:";
        r1.ˊ(r2, r3);
        goto L_0x0005;
    L_0x0033:
        r2 = move-exception;
        r2 = o.cmh.ˎ;
        r3 = "MicroSearchImageUtil";
        r4 = "flattenBitmap out.flush() IOException:";
        r2.ˊ(r3, r4);
        goto L_0x0024;
    L_0x003e:
        r0 = move-exception;
        r0 = o.cmh.ˎ;	 Catch:{ all -> 0x0068 }
        r2 = "MicroSearchImageUtil";
        r3 = "flattenBitmap Could not write icon ";
        r0.ˊ(r2, r3);	 Catch:{ all -> 0x0068 }
        r0 = 0;
        r0 = new byte[r0];	 Catch:{ all -> 0x0068 }
        r1.flush();	 Catch:{ IOException -> 0x005d }
    L_0x004e:
        r1.close();	 Catch:{ IOException -> 0x0052 }
        goto L_0x0005;
    L_0x0052:
        r1 = move-exception;
        r1 = o.cmh.ˎ;
        r2 = "MicroSearchImageUtil";
        r3 = "flattenBitmap out.close() IOException:";
        r1.ˊ(r2, r3);
        goto L_0x0005;
    L_0x005d:
        r2 = move-exception;
        r2 = o.cmh.ˎ;
        r3 = "MicroSearchImageUtil";
        r4 = "flattenBitmap out.flush() IOException:";
        r2.ˊ(r3, r4);
        goto L_0x004e;
    L_0x0068:
        r0 = move-exception;
        r1.flush();	 Catch:{ IOException -> 0x0070 }
    L_0x006c:
        r1.close();	 Catch:{ IOException -> 0x007b }
    L_0x006f:
        throw r0;
    L_0x0070:
        r2 = move-exception;
        r2 = o.cmh.ˎ;
        r3 = "MicroSearchImageUtil";
        r4 = "flattenBitmap out.flush() IOException:";
        r2.ˊ(r3, r4);
        goto L_0x006c;
    L_0x007b:
        r1 = move-exception;
        r1 = o.cmh.ˎ;
        r2 = "MicroSearchImageUtil";
        r3 = "flattenBitmap out.close() IOException:";
        r1.ˊ(r2, r3);
        goto L_0x006f;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.cms.ˏ(android.graphics.Bitmap):byte[]");
    }
}
